﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;

using WSU.Cheka.HelloWCF.Contracts;

namespace WSU.Cheka.HelloWCF.Services
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
    public sealed class WsuService : IWsuContract
    {
        #region "member variables"

        private IDictionary<string, int> m_departments;

        #endregion

        #region "constructor"

        /// <summary>
        /// to let Host automatically load from the assembly (by using reflection)
        /// the class implementing a service must have a public constructor having no arguments
        /// </summary>
        public WsuService()
        {
            m_departments = new Dictionary<string, int> 
            {
                {"EE",5},
                {"CS",10}
            };
        }

        #endregion

        #region "implement interface"

        public string[] GetDepartments()
        {
            return m_departments.Keys.ToArray();
        }

        public int GetNumberByDepartment(string departName)
        {
            return m_departments[departName];
        }

        public void AddDepartment(string departName, int number)
        {
            m_departments.Add(departName, number);
        }

        #endregion
    }
}